﻿using SIG.Core;
using SIG.Resources;
using SIG.Resources.Admin;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace SIG.Model
{
    public partial class Product : AuditableEntity<int>
    {
        public Product()
        {
            this.EntityName = EntityNames.Product;
            this.Categories = new HashSet<Category>();
            this.ProductPhotoes = new HashSet<ProductPhoto>();
        }

        [Display(Name = "产品型号", Prompt = "产品型号")]
        [Required(ErrorMessage = "请输入产品型号")]
        public string ProductNo { get; set; }
        [Display(Name = "产品名称", Prompt = "产品名称")]
        [Required(ErrorMessage = "请输入产品名称")]
        public string ProductName { get; set; }

    
          [Display(Name = "产品描述", Prompt = "产品描述")]
          [AllowHtml]
        public string Body { get; set; }

         [Display(Name = "摘要", Prompt = "摘要")]
        public string Description { get; set; }
       

        [Display(Name = "缩略图", Prompt = "缩略图")]
        public string Thumbnail { get; set; }


        [Display(Name = "显示")]
        public bool Active { get; set; }
        [Display(Name = "推荐")]
        public bool Recommend { get; set; }
        
        public int ViewCount { get; set; }


         public virtual ICollection<Category> Categories { get; set; }
      
        //public string CategoryIds { get; set; }

        [Display(Name = "产品分类")]
        public string[] PostCategoryIds { get; set; }

        public virtual ICollection<ProductPhoto> ProductPhotoes { get; set; }


         public string CategoryTitle
         {
             get
             {
                 if (this.Categories != null)
                 {
                     string[] q = (from i in this.Categories
                                   select i.Title).ToArray();
                     return string.Join("、", q);
                 }

                 return string.Empty;
             }

         }


    }
}
